<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <title>招标阶段设置</title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp" %>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>招标阶段设置</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active">药品招标管理</li>
            <li class="active">采购项目管理</li>
            <li class="active">招标阶段设置</li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class=" form-inline">
                    <div class="form-group form-group-xs">
                	    <label for="txtDrugName">项目名称：</label>
					    <select class="form-control" style="width:220px;" id="projId" name="projId"></select>
                	</div>
                    <div class="form-group form-group-xs">
                        <label for="txtDrugForm">项目状态：</label>
                        <select class="form-control"  id="status" name="status">
                        	<option value="">请选择</option>
                        	<option value="1">启用</option>
                        	<option value="0">停用</option>
                        </select>
                    </div>
                    <button type="button" onclick="gridSerch()" class="btn btn-success btn-sm">查&nbsp;询</button>
                </div>
            </div>
        </div>

        <table class="jqgrid" id="gridlist"></table>
           <div class=" box box-warning bottongroup"></div>

    </section>
    <form action="${ctx}/bidProjCompany/toList.html" method="post" id="Form">
    <input type="hidden" name="projId" id="projId">
    <input type="hidden" name=newname id="newname">
    </form>
     <form action="${ctx}/bidProject/toHospList.html" method="post" id="FormAddhosp">
    <input type="hidden" name="projIdAddhosp" id="projIdAddhosp">
    <input type="hidden" name="name" id="name">
    </form>
      <form action="${ctx}/bidProject/toCompList.html" method="post" id="FormAddcomp">
    <input type="hidden" name="projIdAddcomp" id="projIdAddcomp">
    <input type="hidden" name="compName" id="compName">
    </form>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script type="text/javascript">
        $(function () {
            $("#gridlist").jqGrid({
                url: "${ctx}/bidProject/getDataList.html?orderBy=2",
                mtype: "POST",
                datatype: "json",
                autowidth: true,
                shrinkToFit:true,
                height: 270,
                colNames: ['操作','projId','项目名称','招标开始日期','招标结束日期','采购开始日期','采购结束日期','状态'],
                colModel: [
                    { name: 'operate', width: 60, align: 'center' ,sortable: false,
                    	formatter: function (val, opts, rowdata) {
                    		var str ="";
                    		str += "<a href='javascript:void(0);' onclick='toCheckPassword(\""+rowdata.projId+"\",\""+rowdata.name+"\")' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -140px -20px' class='opIcon' title='时间设置'></a>";
                    		return str;
                    	}	
					},
                    { name: 'projId', key:true,hidden:true,width: 40, align: 'center' ,sortable: false},
                    { name: 'name', width: 160, align: 'left' ,sortable: false},
                    { name: 'projStarttime', width: 100, align: 'center' ,sortable: false},
                    { name: 'projEndtime', width: 100, align: 'center' ,sortable: false},
                    { name: 'starttime', width: 100, align: 'center' ,sortable: false},
                    { name: 'endtime', width: 100, align: 'center' ,sortable: false},
                    { name: 'status', width: 60, align: 'center' ,sortable: false,
						formatter : function(val, opts,rowdata) {
							if (val == 1) {
								return "启用";
							} else if (val == 0) {
								return "停用";
							}
					}}
                   
                ],
                rowNum: 0,
                rownumbers: true,
                viewrecords: true,
                caption: "采购项目列表",
                jsonReader: {
                    repeatitems: false  
                },
                loadComplete: function (data) { //完成服务器请求后，回调函数
                	 formatSelect("#projId",data.rows);
                }
            });
            $("#gridlist").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
        });
      //查询
        function gridSerch() {
        	var projId = $("#projId").val();
        	var status = $("#status").val();
    		$("#gridlist").jqGrid('setGridParam',{  
    	        datatype:'json',
    	        postData:{
    	        		"projId":projId,
    	        		"status":status
    	        		}
    	    }).trigger("reloadGrid"); //重新载入  
    	}
      //设置招标阶段设置
        function toCheckPassword(projId,name){
        	$.post("${ctx}/bidProject/getPasswordInfo.html", {
        		projId:projId
        	}, function(result){
        		if(result){
	        		var result = eval("("+result+")");
	        		if(result.firstSetPswd){
	        			$.HN.message.alert("请先去密码管理设置密码！", "消息","warn");
	        		}else{
	        			 $.HN.dialog.open({
		        	             id:"password",
		        	             title:name,
		        	             url:" ${ctx}/bidProject/toCheckPassword.html?projId="+projId+"&name="+name,
		        	             width:"800px",
		        	             height:"300px"
	        	             }
	        	         );
	        		}
        		}else{
        			$.HN.message.alert("数据异常！", "消息","error");
        		}
        	});
        }
    </script>
</body>
</html>